package com.zkthink.ceres.order.service;

import com.zkthink.base.R;
import com.zkthink.base.service.SuperService;
import com.zkthink.ceres.member.dto.AddressDTO;
import com.zkthink.ceres.order.dto.*;
import com.zkthink.ceres.order.entity.Order;
import com.zkthink.ceres.order.vo.*;
import com.zkthink.ceres.product.dto.IdQueryDTO;
import com.zkthink.ceres.product.dto.PageQueryDTO;
import com.zkthink.ceres.store.entity.Store;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 业务接口
 *
 * </p>
 *
 * @author JustArgo
 * @date 2020-05-10
 */
public interface OrderService extends SuperService<Order> {

    /**
     * 下单方法
     *
     * @return
     * @author JustArgo 2020/5/11 22:36
     */
    R<PlaceOrderVO> placeOrder(PlaceOrderDTO placeOrderDTO);

    R<OrderListVO> findSalesOrderList(FindOrderListDTO findOrderListDTO);


    /**
     * 支付订单
     *
     * @param mid
     * @param orderCode
     * @param ip
     * @return
     */
    R<Object> payOrder(Long mid, String orderCode, String ip);

    /**
     * 继续付款
     *
     * @return
     * @author JustArgo 2020/5/30 20:37
     */
    R<CountinuePayVo> continuePay(ContinuePayOrderDTO continuePayOrderDTO);

    /**
     * 订单付款
     *
     * @return
     * @author JustArgo 2020/5/12 22:44
     */
    R<String> payOrderCallBack(PayOrderCallbackDTO payOrderCallbackDTO);


    /**
     * 查询订单列表
     *
     * @return
     * @author JustArgo 2020/5/13 0:05
     */
    R<OrderListVO> findOrderList(FindOrderListDTO findOrderListDTO);

    /**
     * 申请退款
     *
     * @return
     */
    R<MoneyReturnVO> applyReturnMoney(ApplyReturnMoneyDTO applyReturnMoneyDTO);

    /**
     * 商家审核退款
     *
     * @param auditReturnMoneyDTO 审核退款对象
     * @return
     * @author JustArgo 2020/5/13 22:17
     */
    R<Boolean> auditReturnMoney(AuditReturnMoneyDTO auditReturnMoneyDTO);

    /**
     * 退款回调
     *
     * @param moneyReturnCallbackDTO 退款成功回调对象
     * @return
     * @author JustArgo 2020/5/13 22:41
     */
    R<Boolean> moneyReturnCallback(MoneyReturnCallbackDTO moneyReturnCallbackDTO);

    /**
     * 发货
     *
     * @return
     * @author JustArgo 2020/5/13 23:03
     */
    R<Boolean> sendGoods(SendGoodsDTO sendGoodsDTO);

    /**
     * 申请退货
     *
     * @return
     */
    R<GoodsReturnVO> applyReturnGoods(ApplyReturnGoodsDTO applyReturnGoodsDTO);

    /**
     * 快递订阅回调接口
     *
     * @param request
     */
    void expressSubscriptionCallbackInterface(HttpServletRequest request);

    /**
     * 商家审核退货
     *
     * @return
     * @author JustArgo 2020/5/15 21:41
     */
    R<Boolean> auditReturnGoods(AuditReturnGoodsDTO auditReturnGoodsDTO);

    /**
     * 填写退货物流
     *
     * @return
     * @author JustArgo 2020/5/15 23:35
     */
    R<Boolean> sendReturnGoods(SendReturnGoodsDTO sendReturnGoodsDTO);

    /**
     * 确认收到退货，并选择退款或拒绝退款
     *
     * @return
     * @author JustArgo 2020/5/15 23:59
     */
    R<Boolean> confirmReturnGoods(ConfirmReturnGoodsDTO confirmReturnGoodsDTO);

    /**
     * 结算
     *
     * @return
     * @author JustArgo 2020/5/16 0:56
     */
    R<SettlementVO> settlement(SettlementDTO settlementDTO);

    /**
     * 取消退款申请
     *
     * @return
     * @author JustArgo 2020/5/16 22:28
     */
    R<Boolean> cancelRefund(Long mid, Long moneyReturnId);

    /**
     * 取消退货申请
     *
     * @return
     * @author JustArgo 2020/5/16 22:29
     */
    R<Boolean> cancelReturnGoods(Long mid, Long goodsReturnId);

    /**
     * 取消订单
     *
     * @return
     * @author JustArgo 2020/5/17 0:26
     */
    R<Boolean> cancelOrder(Long mid, Long orderId);

    /**
     * 确认收货
     *
     * @return
     * @author JustArgo 2020/5/17 0:33
     */
    R<Boolean> confirmReceiveGooods(Long mid, Long orderId);

    /**
     * 查询订单详情
     *
     * @return
     * @author JustArgo 2020/5/17 23:19
     */
    R<OrderDetailVO> getOrderDetail(Long mid, Long orderId);

    /**
     * 管理后台搜索订单列表
     *
     * @return
     * @author JustArgo 2020/5/19 0:53
     */
    R<AdminOrderListDTO> findAdminOrderList(AdminOrderSearchParamDTO adminOrderSearchParamDTO);

    R<AdminOrderListByMonthDTO> findAdminOrderListByMonth(AdminOrderSearchParamDTO adminOrderSearchParamDTO);

    /**
     * 管理后台搜索售后订单
     *
     * @return
     * @author JustArgo 2020/5/22 0:50
     */
    R<AdminOrderListDTO> findAdminReturnOrderList(AdminOrderSearchParamDTO adminOrderSearchParamDTO);

    /**
     * 查询订单详情
     *
     * @return
     * @author JustArgo 2020/5/22 1:12
     */
    R<AdminOrderDetailDTO> findAdminOrderDetail(IdQueryDTO idQueryDTO);

    /**
     * 定时关闭待付款超时的订单
     *
     * @return
     * @author JustArgo 2020/5/26 22:51
     */
    R<Integer> closeOvertimeOrder();

    /**
     * 自动确认收货
     *
     * @return
     * @author JustArgo 2020/5/27 20:17
     */
    R<Integer> autoReceiveGoods();

    /**
     * 统计当天订单数据
     *
     * @return
     */
    Map<String, Object> countTodayOrder(Map<String, Object> param);

    /**
     * 查询售后列表
     *
     * @return
     * @author JustArgo 2020/5/30 22:51
     */
    R<ReturnListVO> findReturnList(PageQueryDTO pageQueryDTO);

    /**
     * 删除订单
     *
     * @return
     * @author JustArgo 2020/5/31 13:29
     */
    R<Boolean> delOrder(Long mid, Long orderId);

    /**
     * 根据订单编号 查询子订单列表，如果订单编号本身是子订单，则返回该子订单即可
     *
     * @return
     * @author JustArgo 2020/5/31 14:43
     */
    R<List<Order>> findChildOrderList(String orderCode);

    /**
     * 删除售后订单
     *
     * @return
     * @author JustArgo 2020/5/31 14:55
     */
    R<Boolean> delReturnOrder(Long mid, IdTypeQueryDTO idTypeQueryDTO);

    /**
     * 生成支付二维码
     *
     * @param payQrCodeDTO
     * @return
     */
    R<String> generatePayQrCode(PayQrCodeDTO payQrCodeDTO);

    /**
     * 查询二维码支付结果
     *
     * @param orderId
     * @return
     */
    R<String> queryPayQrCodeResult(String orderId);

    /**
     * 查询某个用户的订单统计信息
     *
     * @param mid
     * @return
     */
    MemberOrderStatistics getOrderStatisticsByMid(Long mid);

    /**
     * 查询快递信息
     *
     * @return
     * @author 善泉 2020/7/8 12:13
     */
    ShippingDTO getShippingTrace(String shipperCode, String logisticCode);


    /**
     * 查询某个售后单的详情
     *
     * @param returnType
     * @param returnCode
     * @return
     */
    R<ReturnDetailVO> getReturnDetail(Integer returnType, String returnCode);

    Map<String, Object> getOrderStatementOfAccount(String mid, Date time1, Date time2);

    /**
     * 获取已完成并且超过7天订单
     *
     * @return
     */
    List<Order> getFinishOrderIdList();

    /**
     * 根据区域查收货地的订单的OrderProduct id
     *
     * @param dto
     * @return
     */
    List<Long> getOrederIdByShoHuoAddress(AddressDTO dto);


    /**
     * 查询订单数量
     *
     * @return
     */
    R<AdminOrderNumDTO> findAdminOrderNum();

    /**
     * 查询全部订单数量 查询全部订单金额
     *
     * @return
     */
    Map storeAll(Store store);
}
